Extension::JsonToResultSetEx Method
Syntax
.ToResultSetEx as SQL::ResultSet (json as C, settings as extension::ToResultSetSettings)
Arguments
- json
Json data used to populate the result set object
- settings
ResultSet Settings, more options for creating a result set object
Description
Create a result set from json and optional table info (schema).
Example
dim rss as extension::ToResultSetSettings rss.RowsAffected = 1 rs = extension::JSON::ToResultSetEx("[{\"fname\" : \"john\" , \"lname\" : \"Public\" }",rss) ? rs.ToString() = "john Public" ? rs.CallResult.RowsAffected = 1
The schemaInFirstRow Option
JSON Data that comes in a more compact form using arrays, where the column names are supplied in the first row are available through the schemaInFirstRow option.
dim json as c = <<%json% { "range": "Customers!A1:Z998", "majorDimension": "ROWS", "values": [ [ "id", "firstname", "lastname", "company" ], [ "1", "john", "public", "Amalgamated LLT" ], [ "2", "fred", "jones", "ACME" ] ] } %json% json = json_extract(json,"values") dim trss as extension::ToResultSetSettings trss.schemaInFirstRow = .t. dim res as SQL::ResultSet res = Extension::Json::ToResultSetEx( json , trss ) ?res.toJson() [ {"id" : "1", "firstname" : "john", "lastname" : "public", "company" : "Amalgamated LLT"}, {"id" : "2", "firstname" : "fred", "lastname" : "jones", "company" : "ACME"} ]